﻿
using Blog.Core.EFcore;
using Blog.Core.IRepositories;
using Microsoft.EntityFrameworkCore;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Blog.Core.Repositories
{
    public class UnOfWork:IUnOfWork
    {
        private readonly DbContext db;

        public UnOfWork(DbContext db)
        {
            this.db = db;
        }
        /// <summary>
        /// 获取上下文
        /// </summary>
        /// <returns></returns>
        public DbContext GetDbContext()
        {
            return db;
        }
        /// <summary>
        /// 返回受影响行数
        /// </summary>
        /// <returns></returns>
        public async Task<int> SaveChanges()
        {
            return await db.SaveChangesAsync();
        }
    }
}
